package com.parking.carsystem.parkingchargesystem.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.google.gson.Gson;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response;
import com.parking.carsystem.parkingchargesystem.R;
import com.parking.carsystem.parkingchargesystem.common.Constant;
import com.parking.carsystem.parkingchargesystem.module.UserInfoModel;

import butterknife.BindView;

public class UserRechargeActivity extends BaseActivity implements View.OnClickListener {
    @BindView(R.id.back)
    ImageView back;
    @BindView(R.id.text)
    TextView text;
    @BindView(R.id.money)
    TextView money;
    @BindView(R.id.recharge_message)
    RelativeLayout rechargeMessage;
    @BindView(R.id.cash_withdrawal)
    RelativeLayout cashWithdrawal;
    @BindView(R.id.recharge_record)
    RelativeLayout rechargeRecord;
    private UserInfoModel userInfoModel;

    @Override
    protected int getContentViewId() {
        return R.layout.activity_recharge;
    }

    @Override
    public void initView() {
        text.setText("我的钱包");
        back.setVisibility(View.VISIBLE);
        cashWithdrawal.setOnClickListener(this);
        rechargeMessage.setOnClickListener(this);
        rechargeRecord.setOnClickListener(this);
    }

    @Override
    public void initData() {
        getUserInfo();
    }


    @Override
    public void onClick(View v) {
        Intent intent = null;
        switch (v.getId()){
            case R.id.recharge_message:
                intent = new Intent(this,RechargeMoneyActivity.class);
                startActivityForResult(intent,0);
                break;
            case R.id.cash_withdrawal:
                showToast("敬请期待");
                break;
            case R.id.recharge_record:
                 intent = new Intent(this,RechargeRecordActivity.class);
                startActivity(intent);
                break;
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if(resultCode == Constant.MONTHLYSUBSCRIPTIONPARKING){
            getUserInfo();
        }
    }

    @Override
    public void updateData(UserInfoModel userInfoModel) {
        if (userInfoModel.data != null && userInfoModel.data.fee > 0) {
            money.setText(String.valueOf(userInfoModel.data.fee));
        }
    }
}
